<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use think\Db;

class NavControllerController extends HomeBaseController
{
    public function nav()
    {
        $nav = Db::name('nav_menu')->where('status',1)->select();
        $nav=$nav->toArray();
        foreach($nav as &$value){
            if(strstr($value['href'],'action')){
                $url_earli = json_decode($value['href'],true);
                $url_now = url($url_earli['action'],$url_earli['param']);
            }else{
                $url_now = "/";
            }

            $value['href'] = $url_now;
        }

        $this->assign('nav',$nav);
        return $this->fetch(':nav');
    }

}